<?php
require_once("includes/func.php");

$act = intval($_GET['act']);
switch ($act) {
default:
	$myView = new Pager; //pagination
	$myView -> page_calculate("blog", " ORDER BY `id` DESC ");
	$query1 = $myView -> page_list();
	require_once("includes/themes/" . THEME . "/index.php");
	break;
	
case 1: //topic body
	$url = $_GET['url'];
	$myView = new Pager;
	$getNews = new GetNews;
	
	$myCount = $myView -> get_count("blog", "WHERE `url` = '". mysql_real_escape_string($url) ."'");
	if ( $myCount != 1 ) //if no finded
	{
		header("HTTP/1.1 301 Moved Permanently");
		header("Location: ". HOME ."/error.php?code=1");
		break;
	}
	
	$getNews -> getPostData($url, "byUrl");
	require_once("includes/themes/" . THEME . "/page.php");
	break;
	
case 2: // get tags
	$tag = urldecode($_GET['tag']);
	$myView = new Pager; //pagination
	$myView -> page_calculate("blog", " WHERE `tags` LIKE '%". mysql_real_escape_string($tag) ."%' ORDER BY `id` DESC");
	$query1 = $myView -> page_list();
	require_once("includes/themes/" . THEME . "/tags.php");
	break;
	
case 4: // add Comment
	$myTitle = "Добавление комментария! / ". TITLE;
	get_header($myTitle);
	$pager = new Posting;
	echo '<div class="message">';
	echo $pager -> commentAdd($_POST['comment'], $_GET['post_id'], $_POST['mail'], $_POST['username']);
	echo '</div>';
	get_footer();
	
	break;
}

?>